*******************************************************************
*This file builds wage data by education level from the Census/ACS*
*******************************************************************

use "$list/czones_list.dta", clear
expand 2
gen year=1990
bys czone: replace year=2000 if _n==2

merge m:1 czone using "$clean_data_lmarket/czone1970_Wages.dta", assert(1 3) nogenerate
merge m:1 czone using "$clean_data_lmarket/czone1990_Wages.dta", assert(1 3) nogenerate
merge m:1 czone using "$clean_data_lmarket/czone2000_Wages.dta", assert(1 3) nogenerate
merge m:1 czone using "$clean_data_lmarket/czone2008_Wages.dta", assert(1 3) nogenerate

merge m:1 czone using "$clean_data_lmarket/czone1970_WagesHighLow.dta", assert(1 3) nogenerate
merge m:1 czone using "$clean_data_lmarket/czone1990_WagesHighLow.dta", assert(1 3) nogenerate
merge m:1 czone using "$clean_data_lmarket/czone2000_WagesHighLow.dta", assert(1 3) nogenerate
merge m:1 czone using "$clean_data_lmarket/czone2008_WagesHighLow.dta", assert(1 3) nogenerate

*Wages
foreach var in hrwage_ln yrwage_ln {
foreach type in bachelor associate high less low {

gen d_`var'_`type'=0.7*100*(ipums_`var'_`type'_2000-ipums_`var'_`type'_1990) if year==1990
replace d_`var'_`type'=100*(ipums_`var'_`type'_2008-ipums_`var'_`type'_2000) if year==2000

}
}

*College wage premium
foreach year in 1990 2000 2008 {
foreach var in hrwage yrwage {

*Education levels premia
gen ipums_`var'_premiumBL_`year' = ipums_`var'_bachelor_`year'/ipums_`var'_less_`year'
gen ipums_`var'_premiumAL_`year' = ipums_`var'_associate_`year'/ipums_`var'_less_`year'
gen ipums_`var'_premiumBA_`year' = ipums_`var'_bachelor_`year'/ipums_`var'_associate_`year'

*College vs non-college
gen ipums_`var'_premiumHL_`year' = ipums_`var'_high_`year'/ipums_`var'_low_`year'

}
}

foreach var in hrwage yrwage {
foreach type in premiumBL premiumAL premiumBA premiumHL {

gen d_`var'_`type'=0.7*100*(ipums_`var'_`type'_2000-ipums_`var'_`type'_1990) if year==1990
replace d_`var'_`type'=100*(ipums_`var'_`type'_2008-ipums_`var'_`type'_2000) if year==2000

}
}

gen wage_earners_1990 = wage_earners_bachelor_1990+wage_earners_associate_1990+wage_earners_less_1990 if !mi(wage_earners_bachelor_1990) & !mi(wage_earners_associate_1990) & !mi(wage_earners_less_1990)

save "$final_data_outcomes/czone_Wages.dta", replace






